package main

import (
	"fmt"
	"strconv"
)

func main() {
	s := make([]string, 3)
	// 等价于
	//s :=  []string{"", "", ""}
	for i := 0; i < 3; i++ {
		s[i] = strconv.Itoa(i)
	}
	fmt.Println("s : ", s, "len(s) : ", len(s), "address : ")
	fmt.Printf("%p\n", &s)
	s = append(s, "3")
	s = append(s, "4")
	fmt.Println("s append : ", s, "len(s) : ", len(s), "cap(s)", cap(s), "address : ")
	fmt.Printf("%p\n", &s)

	c := make([]string, len(s))
	copy(c, s)
	fmt.Println("c : ", c, "len(c) : ", len(c), "address : ")
	fmt.Printf("%p\n", &c)

	s24 := s[2:4]
	fmt.Println("s[2:4] : ", s24, "len(s24) : ", len(s24), "cap(24)", cap(s24), "address : ")
	fmt.Printf("%p\n", &s24)

	s25 := s[2:5]
	fmt.Println("s[2:5] : ", s25, "len(s25) : ", len(s25), "cap(25)", cap(s25), "address : ")
	fmt.Printf("%p\n", &s25)

	s26 := s[2:6]
	fmt.Println("s[2:6] : ", s26, "len(s26) : ", len(s26), "cap(26)", cap(s26), "address : ")
	fmt.Printf("%p\n", &s26)

	// out of range
	//s27 := s[2:7]
	//fmt.Println("s[2:7] : ", s27, "len(s27) : ", len(s27), "cap(27)", cap(s27), "address : ")
	//fmt.Printf("%p\n", &s27)
}
